<script src='http://extjs.cachefly.net/ext-4.0.2a/ext-all.js'></script>
<script src='../events.json'></script>
<script>
var eventn = 0;
function gettrack(event)
{
    try{
    var url = 'http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&artist='+event[1].split(',')[0]+'&api_key=b25b959554ed76058ac220b7b2e0a026&format=json'
    Ext.Ajax.request({
    url:url,
    success: function(response, opts)
    {
        try{
        var data = Ext.decode(response.responseText);
        for(var i = 0; i < data.toptracks.track.length; i++){
            if(data.toptracks.track[i].streamable)
            {
                console.log(data.toptracks.track[i].url);
                event.push(data.toptracks.track[i].url);
                break;
            }
        }
        }catch(e){
            event.push('');
        }
        window.setTimeout(function(){gettrack(events[++eventn]);}, 1000);
    }
    });
    } catch(e){
        window.setTimeout(function(){gettrack(events[++eventn]);}, 1000);
    }
}
gettrack(events[eventn]);

</script>
<body>  
<pre>
